import java.util.Arrays;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86138
 * Date: 2024-07-06
 * Time: 10:09
 */
class Stu{
    private String name;
    private int age;
    private int num;

    public void setAge(int age) {
        this.age = age;
    }

    public int getAge() {
        return age;
    }
}

public class Sevev {
    public static void main1(String[] args) {
        Stu stu = new Stu();
        stu.setAge(18);
        int ret = stu.getAge();
        System.out.println(ret);
    }



    //二分查找
    public static void main2(String[] args) {
        int[] array = {5,8,9,4,57,3,4543,367,45};
        Arrays.sort(array);
        System.out.println(Arrays.toString(array));
        int left = 0;
        int right = array.length-1;
        int mid = (left+right)/2;

        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();

        while(left<=right){
            mid = (left + right)/2;
            if(array[mid] == num){
                System.out.println("找到了,下标是"+mid);
                return;
            }else if(array[mid]<num){
                left++;
            }else{
                right--;
            }
        }
        System.out.println("没找到");
    }


    //因为数组中只有一个数字出现一次 则其他出现两次的数字用异或运算后都是0，最终整个数组异或运算的结果即为所求。
    public static void main3(String[] args) {
        int [] array = {1,2,3,4,5,6,7,8,7,6,8,5,4,1,2};
        int ret = 0;
        for(int i = 0;i<array.length;i++){
            ret = ret ^ array[i];
        }
        System.out.println(ret);
    }


    //找出出现次数超过一半的数字
    public static void main4(String[] args) {
        int[] array = {2,2,1,1,1,2,2};
        Arrays.sort(array);
        System.out.println(array[array.length/2]);
    }


    public static boolean jedge(int[] array){
        int count = 0;
        for(int i = 0;i < array.length;i++){
            if(array[i]%2!=0){
                count++;
                if(count == 3){
                    return true;
                }
            }else{
                count = 0;
            }
        }
        return false;
    }

    //给你一个整数数组 arr，请你判断数组中是否存在连续三个元素都是奇数的情况：如果存在，请返回 true ；否则，返回 false
    public static void main(String[] args) {
        int[] array1 = {1,2,34,3,4,5,7,23,12};
        int[] array = {2,6,4,1};
        boolean ret = jedge(array);
        System.out.println(ret);
    }
}
